package com.leetcode.LC;

import java.util.Arrays;

public class LC242 {
    public boolean isAnagram(String s, String t) {
        if (s.length()!=t.length()){
            return false;
        }
        char[] charsS = s.toCharArray();
        char[] charsT = t.toCharArray();
        int[] ints = new int[26];
        Arrays.fill(ints,0);
        int[] ints2 = new int[26];
        Arrays.fill(ints2,0);
        for (int i = 0; i < s.length(); i++) {
            ints[charsS[i]-'a']++;
            ints2[charsT[i]-'a']++;
        }
/*        System.out.println(Arrays.toString(ints));
        System.out.println(Arrays.toString(ints2));*/
        if (Arrays.toString(ints).equals(Arrays.toString(ints2))){
            return true;
        }
        return false;
    }

    public static void main(String[] args) {
        System.out.println(new LC242().isAnagram("rat", "tar"));
    }
}
